package com.jinlia.show.modules.wxapp.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jinlia.show.modules.base.constant.DataBoardTypeEnum;
import com.jinlia.show.modules.base.model.vo.DeliveryOrderVO;
import com.jinlia.show.modules.base.system.entity.DeliveryOrder;
import com.jinlia.show.modules.base.model.query.DeliveryOrderQuery;
import com.jinlia.show.modules.base.model.po.DeliveryOrderPO;
import com.jinlia.show.modules.base.system.service.DeliveryOrderMapperService;
import com.jinlia.show.modules.base.system.service.OrderLogMapperService;
import com.jinlia.show.modules.base.model.bo.DataBoardBO;
import com.jinlia.show.modules.wxapp.service.WorkingTableService;
import com.jinlia.show.modules.wxapp.websocket.WebSocketService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 订单管理
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/manager/orderDelivery")
public class ManagerDeliveryOrderController {
//    @Autowired
//    private DeliveryOrderMapperService deliveryOrderMapperService;
//    @Autowired
//    private WorkingTableService workingTableService;
//    @Autowired
//    private OrderLogMapperService orderTrackMapperService;
//    @Autowired
//    private WebSocketService webSocketService;
//
//    @GetMapping("{orderId}")
//    public DeliveryOrderPO getById(@PathVariable("orderId") Long orderId) {
//        DeliveryOrder byId = deliveryOrderMapperService.getById(orderId);
//
//        return DeliveryOrderPO.fromEntity(byId);
//    }
//
//    /**
//     * 分页查询发货单
//     *
//     * @param deliveryOrderQuery
//     * @return
//     */
//    @PostMapping("po")
//    public Page<DeliveryOrderVO> getPagePO(@RequestBody DeliveryOrderQuery deliveryOrderQuery) {
//        return deliveryOrderMapperService.getPagePO(deliveryOrderQuery);
//    }
//
//    /**
//     * 商家动作:
//     * 接单确认
//     */
//    @PostMapping("confirm")
//    public DeliveryOrder confirmDeliveryOrder(@RequestBody DeliveryOrder deliveryOrder) {
//        deliveryOrder = deliveryOrderMapperService.confirmDeliveryOrder(deliveryOrder);
//        webSocketService.broadcastMsg("有新的订单生成!!!");
//        return deliveryOrder;
//    }
//
//    /**
//     * 商家动作:
//     * 制作完成(开始配送)
//     */
//    @PostMapping("start")
//    public Boolean startDeliveryOrder(@RequestBody DeliveryOrder deliveryOrder) {
//        deliveryOrderMapperService.startDeliverOrder(deliveryOrder);
//        webSocketService.broadcastMsg("有新的订单生成!!!");
//        return Boolean.TRUE;
//    }
//
//    /**
//     * 商家动作:
//     * 配送完成(配送员确认)
//     */
//    @PostMapping("ok")
//    public Boolean okDeliveryOrder(@RequestBody DeliveryOrder deliveryOrder) {
//        deliveryOrderMapperService.okDeliveryOrder(deliveryOrder);
//        return Boolean.TRUE;
//    }
//
//    /**
//     * 顾客动作:
//     * 配送完成(配送员确认) | 或顾客自取
//     */
//    @PostMapping("user/confirm")
//    public Boolean userConfirmDeliveryOrder(@RequestBody DeliveryOrder deliveryOrder) {
//        deliveryOrderMapperService.userConfirmDeliveryOrder(deliveryOrder);
//        return Boolean.TRUE;
//    }
//
//    /**
//     * 数看板
//     */
//    @PostMapping("board")
//    private List<DataBoardBO> dataBoard(@RequestBody List<Integer> valueList) {
//        List<DataBoardBO> dataBoardBOList = valueList.stream().map(i -> {
//            DataBoardBO dataBoardBO = new DataBoardBO();
//            dataBoardBO.setDataBoardType(DataBoardTypeEnum.getByValue(i));
//            dataBoardBO.setType(dataBoardBO.getDataBoardType().type);
//            return dataBoardBO;
//        }).collect(Collectors.toList());
//        return workingTableService.getDataBoard(dataBoardBOList);
//    }
}
